package com.coding.controller;

import com.coding.base.pojo.BaseModel;
import com.coding.base.pojo.PageQueryModel;
import com.coding.service.PaintService;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @auther wangchenghao
 * @date 2020/7/26
 **/

@Controller
@ResponseBody
@RequestMapping("paint")
public class PaintController {
    @Autowired
    PaintService paintService;

    @ApiOperation(value = "通过id查询诗画资源")
    @RequestMapping(value = "/getById", method = {RequestMethod.GET})
    public BaseModel upimage(@ApiParam(value = "画id", required = true) @RequestParam("paint_id") int paint_id) {
        BaseModel baseModel = new BaseModel();
        try {
            paintService.selectById(paint_id, baseModel);
        } catch (Exception e) {
            e.printStackTrace();
        }

        return baseModel;
    }


    @ApiOperation(value = "查询诗画列表")
    @RequestMapping(value = "/getList", method = {RequestMethod.GET})
    public BaseModel upimage(@ModelAttribute PageQueryModel pageQueryModel) {
        BaseModel baseModel = new BaseModel();
        try {
            paintService.selectList(pageQueryModel, baseModel);
        } catch (Exception e) {
            e.printStackTrace();
        }

        return baseModel;
    }
}
